document.getElementById('speak-button').addEventListener('click', () => {

    window.speechSynthesis.cancel();//播报前建议调用取消的函数，如有正在播报的话音，播报会任务被塞进入队列，只有等上一个语音结束才会执行下一个语音
    //获取语音包
    let listArr = window.speechSynthesis.getVoices();
    for (let i = 0; i < listArr.length; i++) {
        console.log(listArr[i].lang + ' ' + listArr[i].name);
    }


    const text = document.getElementById('text-input').value;
    if (text.trim() === '') {
        alert('请输入中文内容');
        return;
    }

    console.log(text);
    const utterance = new SpeechSynthesisUtterance(text);
    utterance.lang = 'zh-CN';
    window.speechSynthesis.speak(utterance);
});
